package interpreter;

import java.util.ArrayList;
import java.util.List;

public class Variable {
	private String id;
	private Integer valueInt;
	private List<List<String>> valueStringMatchList;
	
	public Variable(String id) {
		this.id = id;
		this.valueInt = (Integer) null;
		this.valueStringMatchList = null;
	}
	
	public Variable(String id, int value) {
		this.id = id;
		this.valueInt = value;
		this.valueStringMatchList = null;
	}
	
	public Variable(String id, ArrayList<List<String>> value) {
		this.id = id;
		this.valueInt = (Integer) null;
		this.valueStringMatchList = value;
	}

	public String getName() {
		return id;
	}

	public void setName(String name) {
		this.id = name;
	}

	public Integer getValueInt() {
		return valueInt;
	}

	public void setValueInt(int valueInt) {
		this.valueInt = valueInt;
		this.valueStringMatchList = null;
	}


	public List<List<String>> getValueStringMatchList() {
		return valueStringMatchList;
	}

	public void setValueStringMatchList(List<List<String>> valueStringMatchList) {
		this.valueStringMatchList = valueStringMatchList;
		this.valueInt = (Integer) null;
	}
	
	public Object getValue() {
		if(valueInt != (Integer)null) {
			return valueInt;
		}
		else if(valueStringMatchList != null) {
			return valueStringMatchList;
		}
		else {
			return null;
		}
	}

	public void setValue(Object value) {
		if(value.getClass().isInstance(List.class)) {
			this.setValueStringMatchList((List<List<String>>) value);
		}
		else if(value.getClass().isInstance(Integer.class)) {
			this.setValueInt((int)value);
		}
	}
	
	
}